<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>根据一个对象创造出无数个对象</title>
</head>
<body>
    <script>
        function User(name) {
            this.name = name;
        }

        User.prototype = {
            constructor:User,
            show(){
                console.log(this.name);
            }
        }

        let lisi = new User("李四");
        console.log(lisi);


        // 根据一个对象创建出新的对象
        function createByObject(obj,...args) {
            let constructor = obj.__proto__.constructor;
            return new constructor(...args);
        }

        let zhangsan = createByObject(lisi,"张三");
        console.log(zhangsan);
        zhangsan.show();
    </script>
</body>
</html>